package com.xkdx.guangguang.fragment.my.setup;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.xkdx.guangguang.module.network.AbsModule;

public class ExchangeShopModule extends AbsModule {
	ProductListInfo productListInfo;

	@Override
	public void parseData() throws Exception {

		backJson = (JSONArray) result;
		try {
			for (int i = 0; i < backJson.length(); i++) {
				jsonObj = (JSONObject) backJson.get(i);
				String sortOfAct = jsonObj.getString("Act");
				if (sortOfAct.equals("getProductList")) {
					productListInfo = parserProductList(jsonObj.getJSONObject("Content"));
				}

			}
		} catch (Exception e) {
			// TODO: handle exception
		}

	}

	private ProductListInfo parserProductList(JSONObject person) throws Exception {
		ProductListInfo productListInfo=new ProductListInfo();
		List<ProdecuListDetail> ProductList = new ArrayList<ProdecuListDetail>();
		try {
			if (person == null) {
				return null;
			}
			JSONObject stut = (JSONObject) person.get("Result");
			productListInfo.setStatus(stut.getString("Status"));

				JSONArray ListInfo = (JSONArray) stut.getJSONArray("ListInfo");
				for (int i = 0; i < ListInfo.length(); i++) {
					ProdecuListDetail prodecuListDetail = new ProdecuListDetail();
					JSONObject info = ((JSONObject) ListInfo.opt(i));
					prodecuListDetail.setLogo(info.getString("Logo"));
					prodecuListDetail.setType(info.getString("Type"));
					prodecuListDetail.setProductCode(info.getString("ProductCode"));
					prodecuListDetail.setProductID(info.getString("ProductID"));
					prodecuListDetail.setProductName(info.getString("ProductName"));
					prodecuListDetail.setProductType(info.getString("ProductType"));
					ProductList.add(prodecuListDetail);
				}
		
			productListInfo.setProdecuListDetail(ProductList);

		} catch (Exception e) {
			throw e;
		}
		return productListInfo;
	}

	public class ProductListInfo implements Serializable {

		private static final long serialVersionUID = 1L;
		private String Status;
		private String Message;

		private List<ProdecuListDetail> prodecuListDetail;

		public List<ProdecuListDetail> getProdecuListDetail() {
			return prodecuListDetail;
		}

		public void setProdecuListDetail(List<ProdecuListDetail> prodecuListDetail) {
			this.prodecuListDetail = prodecuListDetail;
		}

		public String getStatus() {
			return Status;
		}

		public void setStatus(String status) {
			Status = status;
		}

		public String getMessage() {
			return Message;
		}

		public void setMessage(String message) {
			Message = message;
		}

	}

	public class ProdecuListDetail {
		private String ProductID;
		private String ProductName;
		private String Logo;
		private String ProductType;
		private String ProductCode;
		private String Type;

		
		public String getType() {
			return Type;
		}

		public void setType(String type) {
			Type = type;
		}

		public String getProductID() {
			return ProductID;
		}

		public void setProductID(String productID) {
			ProductID = productID;
		}

		public String getProductName() {
			return ProductName;
		}

		public void setProductName(String productName) {
			ProductName = productName;
		}

		public String getLogo() {
			return Logo;
		}

		public void setLogo(String logo) {
			Logo = logo;
		}

		public String getProductType() {
			return ProductType;
		}

		public void setProductType(String productType) {
			ProductType = productType;
		}

		public String getProductCode() {
			return ProductCode;
		}

		public void setProductCode(String productCode) {
			ProductCode = productCode;
		}
	}

}
